<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        h1 {
            text-align: center;
        }

        table {
            margin: 0 auto;
        }

        tr,
        td {
            width: 800px;
            height: 40px;
            text-align: center;
        }
    </style>
    <script src="../../vue.js"></script>

</head>

<body>
    <div id="app">
        <h1>欢迎光临vue开发的银行系统-水果店</h1>
        <table border="1">
            <thead>
                <tr>
                    <th>苹果10￥/斤，折扣《8折》</th>
                </tr>
            </thead>
            <tbody>
                <tr>
                    <td>请输入你需要的斤数:<input type="
                        text" v-model.Number="sx"></td>
                </tr>
                <tr>
                    <td><button @click="cn">结账买单~</button></td>
                </tr>
                <tr>
                    <td>账单：总价：{{sum}}￥元&nbsp;&nbsp;&nbsp;折后价：{{discount}}￥元&nbsp;&nbsp;&nbsp;省了：{{reduce}}￥元</td>
                </tr>
            </tbody>
        </table>
    </div>

    <script>
        Vue.config.productionTip = false;
        new Vue({
            data: {
                sx: '',
                sum: '0',
                discount: '0',
                reduce: '0',
            },
            methods: {
                cn() {
                    this.sum = this.sx * 10
                    this.discount = this.sum * 0.8
                    this.reduce = this.sum - this.discount
                    this.sx = ''
                }
            }
        }).$mount('#app')
    </script>
</body>

</html>